package com.diantou.tiku.utils;


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

/**
 * mybatis自动成代码工具类
 * */


public class MpHelper {

        public static void main(String[] args) {
            AutoGenerator mpg = new AutoGenerator();
            mpg.setGlobalConfig(new GlobalConfig()
                    .setAuthor("wudi")
                    .setActiveRecord(true)
                    .setFileOverride(false)
                    .setOutputDir("D:/IDEAProject/tiku/src/main/java")
                    .setBaseColumnList(true)
                    .setEnableCache(false)
                    .setBaseResultMap(true)
                    .setOpen(false)
                    .setMapperName("I%sMapper")
                    .setXmlName("%sMapper")
                    .setServiceName("I%sService")
                    .setServiceImplName("%sServiceImpl")
                    .setControllerName("%sController")
            );
            mpg.setStrategy(new StrategyConfig()
                    .setNaming(NamingStrategy.underline_to_camel)
                    .setTablePrefix("t_")
                    .setEntityLombokModel(true)
                    .setRestControllerStyle(true)
                    .setInclude(new String[]{"t_user_info"})
            );
            mpg.setDataSource(new DataSourceConfig()
                    .setDbType(DbType.MYSQL)
                    .setUrl("jdbc:mysql://localhost:3306/miaosha?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false")
                    .setUsername("root")
                    .setPassword("123456")
                    .setDriverName("com.mysql.cj.jdbc.Driver")
            );
            mpg.setPackageInfo(new PackageConfig()
                    .setParent("com.diantou.tiku")
                    .setMapper("dao")
                    .setEntity("bean")
                    .setService("service")
                    .setServiceImpl("service.impl")
                    .setXml("mapper")
                    .setController("controller")
            );
            mpg.execute();
        }

}
